import router from '@system.router';
import storage from '@system.storage';
import {HuaweiIdAuthParamsHelper, HuaweiIdAuthManager} from '@hmscore/hms-jsb-account';

export default {
    data: {
        title: "Hello HarmonyOS",
        isHarmonyOS: true,
        phone: '',
        mediate: '',  // 捏合
        mediate_grade: '',  // 手指伸展
        finger: '',  // 
        finger_grade: '',
        tremble: '',
        tremble_grade: '',
        myoelectricity: '',
        myoelectricity_grade: '',
        "setArray": [
            {"dir":"/common/images/mine_message.svg"},
            {"value": "意见反馈"},
            {"dir":"/common/images/mine_set.png"},
            {"value": "系统设置"},
            {"dir":"/common/images/mine_quit.png"},
            {"value": "退出登录"},
            {"dir":"/common/images/mine_about.svg"},
            {"value": "关于"},
        ],

        "dirArray": [
            {"dir":"/common/images/mine_message.svg"},
            {"dir":"/common/images/mine_set.png"},
            {"dir":"/common/images/mine_quit.png"},
            {"dir":"/common/images/mine_about.svg"},
        ],
    },

    onInit(){
        // 从缓存取用户信息，自动登录
        storage.get({
            key: 'id',
            success: data => {
                if(data){
                    this.phone = data
                }
            },
        });

        // 昵称
        storage.get({
            key: 'name',
            success: data => {
                if(data){
                    this.phone = data
                }
            },
        });

        // 从缓存取用户信息，自动登录
        storage.get({
            key: 'id',
            success: data => {
                if(data){
                    this.phone = data
                }
            },
        });

    },

    quit(){

        HuaweiIdAuthManager.getAuthApi().cancelAuthorization().then((result)=>{
            // 帐号取消授权成功
            console.info(this.TAG+"取消授权成功");
            console.info(this.TAG+JSON.stringify(result));
        }).catch((error) => {
            // 帐号取消授权失败
            console.error(this.TAG+"取消授权失败");
            console.error(this.TAG+JSON.stringify(error));
        });
        router.push ({
            uri:'pages/login/login', // 指定要跳转的页面
        })

    },
    exit(){
        router.push({
            uri:"pages/login/login"
        })
    }
}